/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
*  \class	TCoord2D
*  \author 	Jari Saarinen
*  \date 	Fri Mar 10 12:26:30 2006

*  \version: 0.1  
* 
* Implementation for 2D coordinate point (x,y)
*/

#ifndef T_COORD2_D_H
#define T_COORD2_D_H

#include <math.h>
#include "LNMdatastructs.h"

class TCoord2D
{
private: 
	float x;	// X-coordinate 
	float y;	// Y-coordinate
public:
	TCoord2D();
	TCoord2D(float x, float y);
	~TCoord2D();

	//static TCoord2D operator +(const TCoord2D &x,  const TCoord2D &y);
	//static TCoord2D operator -(const TCoord2D &x,  const TCoord2D &y);

    //TCoord2D operator +(const TCoord2D &x,  const TCoord2D &y);
	//TCoord2D operator -(const TCoord2D &x,  const TCoord2D &y);

    TCoord2D operator +(TCoord2D x) const;
	TCoord2D operator -(TCoord2D x) const;


	float getX();
	float getY();
	
	float getPolarDist(); 
	float getPolarAngle();

	void setCoord(float x,float y);
	
	void addCoord(float x, float y);
	void addPolar(float r,float a);
    
    /**
    * Rotates this point around coordinate P
    * @param P Coordinate around which the rotation is done
    * @param alpha rotation angle
    */
    void rotate(TCoord2D P, float alpha);
    
    /**
	* Translates this P amount
	* @param P  the amount which the coordinate should be translated
	*/
	void translate(TCoord2D P);

    

	/**
	* Transforms the TCoord2D value to pixel coordinates
	* @param resolution		The transformation resolution 
	* @return				The transformed pixel Cooddinate
	**/
	TPixelCoord  toPixelCoord(float resolution);

	/**
	* Transforms the TCoord2D value to relative/BasicGrid coordinate system. The 
	* TCoord2d value is given in the global (right-hand cartesian) coordinate system in meters
	* The resolution is the grid size in meters and the upLeft is the coordinate of the 
	* given grid upper left corner. 
	* The output is the pixel coordinate in the "basic grid" coordinate system 
	* (origin is the upper left corner, y-down and x-right)
	* 
	* @param resolution		The transformation resolution 
	* @param upLeft			The upper left corner pixel coordinate in global frame
	* @return				The value in given grid coordinates 
	*/
	TPixelCoord  toRelativePixelCoord(float resolution, TPixelCoord upLeft);

	
};          


#endif


